using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using SqlSugar;

namespace Blog.IRepository
{
    public interface IBaseRepository<T> where T:class, new()
    {
        /// <summary>
        /// 创建
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        Task<bool> CreateAsync(T t);

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        Task<bool> DeleteAsync(int id);

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        Task<bool> EditAsync(T t);

        /// <summary>
        /// 导航查询
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<T> FindAsync(int id);

        /// <summary>
        /// 条件导航查询
        /// </summary>
        /// <returns></returns>
        Task<T> FindAsync(Expression<Func<T, bool>>func);

        /// <summary>
        /// 查询全部
        /// </summary>
        /// <returns></returns>
        Task<List<T>> QueryAsync();

        /// <summary>
        /// 条件查询
        /// </summary>
        /// <returns></returns>
        Task<List<T>> QueryAsync(Expression<Func<T, bool>> func);

        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="page"></param>
        /// <param name="size"></param>
        /// <param name="total"></param>
        /// <returns></returns>
        Task<List<T>> QueryAsync(int page, int size, RefAsync<int> total);

        /// <summary>
        /// 分页条件查询
        /// </summary>
        /// <param name="func"></param>
        /// <param name="page"></param>
        /// <param name="size"></param>
        /// <param name="total"></param>
        /// <returns></returns>
        Task<List<T>> QueryAsync(Expression<Func<T, bool>> func, int page, int size, RefAsync<int> total);
    }
}